// index.js
const app = getApp()
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Page({
    data: {
      userInfo: {},
      hasUserInfo: false,
      avatarUrl: defaultAvatarUrl,
      canIUse: wx.canIUse('button.open-type.getUserInfo')
    },
    
    onLoad() {
      if (wx.getStorageSync('avatarUrl')) {
        wx.switchTab({
          url: '/pages/home2/home2'
        });
      }
    },
    
  onChooseAvatar(e) {
    const { avatarUrl } = e.detail 
    this.setData({
      avatarUrl,
    })
    wx.setStorageSync('avatarUrl', e.detail);
  },
  formSubmit(e){
      console.log('昵称：',e.detail.value.nickname)
      wx.setStorageSync('nickname', e.detail.value.nickname);
  },
  
    goToIndex() {
      // 跳转到首页
      wx.switchTab({
        url: '/pages/home2/home2'
      });
    },
      tohome:function() {
        wx.switchTab({
          url: '/pages/home2/home2'
        });
      }
  })
  